﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FirebirdSql.Data.FirebirdClient;

namespace University
{
    public partial class BOTAN_SADU : University.NAUKOVYI_PIDROZDIL
    {
       
        static string sqlSelect = "SELECT * FROM  BOTAN_SADU";
        FbDataAdapter da = new FbDataAdapter(sqlSelect, con);
        DataTable dt = new DataTable();
        
        public BOTAN_SADU(TreeNode node, ContextMenuStrip s, string com, int id)
            : base(node, s, com, id)
        {
            InitializeComponent();
            node_id = Convert.ToInt32(mynode.Tag.ToString());

            da.Fill(dt);
            bindingSource1.DataSource = dt;
            
         
            richTextBox3.DataBindings.Add("Text", bindingSource1, "VYDY_ROSLYN");
            bindingSource1.Filter = "UNIQUE_NO =" + node_id;
            if (com == "Remove") { Remove("BOTAN_SADY"); }
      
        }
      
        public override void Remove(string name)
        {
            base.Remove(name);
        }

        public override void UpdateForm()
        {
            OpenCon();
            UpdateFild("BOTAN_SADU", "VYDY_ROSLYN", richTextBox3.Text);
            base.UpdateForm();

        }
        public override void InsertFild(string klas)
        {
            OpenCon();

            FbCommand cmdInsert = new FbCommand("INSERT INTO BOTAN_SADU(UNIQUE_NO,VYDY_ROSLYN) VALUES(@1,@2)", con);
            cmdInsert.Parameters.AddWithValue("1", textBox1.Text);
            cmdInsert.Parameters.AddWithValue("2", richTextBox3.Text);
            cmdInsert.ExecuteNonQuery();
            base.InsertFild(klas);
        }

    
    }
}